import { cfg_genrator } from './cfg_genrator';
import { res_genrator } from './res_genrator';
import { image_processor } from './image_processor';
import { resource_check } from './resource_check';
import { ImageCheck } from './ImageCheck'
import { eui_str_extract } from './eui_str_extract';
import { assets_cleaner } from './assets_cleaner';
import { trans_res_generator } from './trans_res_generator';
// import { format_genrator } from './format_genrator'

const GEN_REPORT_TAG = 'report';
const INCLUDE_IMG = 'compose_image';

export default async function main(opt: { act: string, path: string, extra?: string }) {
	let _path = opt.path;
	if (!_path) {
		_path = process.cwd();
	}
	_path = _path.replace(/\\\\?/g, '/');
	_path = _path[_path.length - 1] == '/' ? _path.slice(0, _path.length - 1) : _path;  //确保没有'/'

	if (opt.act == 'res') {
		new res_genrator.ResGenrator().Load(_path, INCLUDE_IMG == opt.extra);
	} else if (opt.act == 'cfg') {
		new cfg_genrator.CfgGenRator(_path, GEN_REPORT_TAG == opt.extra);
	} else if (opt.act == 'img') {
		new image_processor.ImageProcessor(_path).Process();
	} else if (opt.act == "check") {
		new resource_check.ResourceChecker(_path, opt.extra!);
	} else if (opt.act == 'img_size') {
		new ImageCheck.ImageCheck(_path);
	} else if ('eui_str' == opt.act) {
		new eui_str_extract.EuiStrExtract(_path);
	} else if ('clean_assets' == opt.act) {
		new assets_cleaner.AssetsCleaner(_path, opt.extra!);
	} else if ('trans_res' == opt.act) {
		new trans_res_generator.TransResGen(_path);
	}
}


